/**
 * Created by yuris on 19.12.14.
 */
package view {
import components.AbstractGameObjectComponent;

import flash.geom.Point;

import messages.DebugMessage;

import mvcexpress.mvc.Mediator;

import starling.events.Event;

public class AbstractComponentMediator extends Mediator {

    protected function _createViewAsStaticObject(component:AbstractGameObjectComponent):void {
        this._placeView(component);

        if(!component.gameLayer.addSortableObject(component.view)){
            sendMessage(DebugMessage.ERROR_MESSAGE, "GameLayerMediator: can't add object "+component.view.typemodel +
                    " at ["+component.model.position.x+","+component.model.position.y+"] - exactly the same object already exist");
        }
    }

    protected function _placeView(component:AbstractGameObjectComponent):void {
        component.view.angle = component.model.angle;

        var _localPoint:Point = component.gameLayer.getLocalCoordsByQuadrant(component.model.position);
        component.view.x = _localPoint.x;
        component.view.y = _localPoint.y;

    }


}
}
